import Dayjs from 'dayjs'
export default (timestamp) => {
	let currentTime = Dayjs();
	timestamp = Number(timestamp)
	const targetTime = Dayjs(timestamp);
	const diffSeconds = currentTime.diff(targetTime, 'second');
	if (diffSeconds < 60) {
		return '刚刚';
	}
	const diffMinutes = currentTime.diff(targetTime, 'minute');
	if (diffMinutes < 60) {
		return `${diffMinutes}分钟前`;
	}
	const diffHours = currentTime.diff(targetTime, 'hour');
	if (diffHours < 24) {
		return `${diffHours}小时前`;
	}
	const diffDays = currentTime.diff(targetTime, 'day');
	if (diffDays < 30) {
		return `${diffDays}天前`;
	}
	const diffMonths = currentTime.diff(targetTime, 'month');
	if (diffMonths < 12) {
		let Months = diffMonths +1 
		return `${Months}个月前`;
	}
	const diffYears = currentTime.diff(targetTime, 'year');
	return `${diffYears}年前`;
}